
<!DOCTYPE HTML>

<html>
<head>
    <title>商城</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta charset="utf-8" />
    <link rel="shortcut icon" href="/favicon.ico" />
    <link rel="bookmark" href="/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <link rel="stylesheet" href="/assets/css/main.css" />
    <link rel="stylesheet" href="layui/css/layui.css"  media="all">
    <noscript><link rel="stylesheet" href="/assets/css/noscript.css" /></noscript>
</head>
<body>
<div id="wrapper">

    <header id="header">
        <div class="logo">
            <span class="icon fa-rmb"></span>
        </div>
        <div class="content">
            <div class="inner">
                <h1>下单商城</h1>

                <p>售后信息联系VX:fonddream2121</p>
            </div>
        </div>
        <nav>
            <ul>
                <li><a href="#login">下单</a></li>
                <li><a href="#about">查询订单</a></li>
            </ul>
        </nav>
    </header>

    <div id="main">

        <article id="about">
            <h2 class="major">查询订单</h2>
            <form method="post" action="javascript:Search();">
                <div class="field half" id="isPhomeNumSearch" >
                    <label for="pass">联系方式[**邮箱或者手机**]</label>
                    <input type="text" name="pass" id="phoneContentSearch" minlength="5" required="required"/>
                </div>
                <br/>
                <div class="field half">
                    <ul class="actions">
                        <li><input id="search" type="button" value="查询" class="special" onclick="searchGoodsInfo()" /></li>
                        <!--                    <li><input type="reset" value="清空" /></li>-->
                        <!--                    <li style="  color: 0000;  font-size: 30px;"><div><text id="priceDiv"></text></div></li>-->
                        <li><table id="showTables" lay-filter="test" ></table></li>
<!--                        id，时间，金额，内容-->
                    </ul>

                </div>

            </form>
<!--            <p>1、V免签为个人用户提供支付宝、微信的免签约收款解决方案。</p>-->
<!--            <p>2、V免签为开源免费产品，请勿二次出售。</p>-->
<!--            <p>3、V免签仅供交流学习使用，请勿用于商业用途。</p>-->
<!--            <p>4、请遵守相关法律法规，请勿用于非法用途。</p>-->
<!--            <p><input type="submit" value="获取V免签" class="" onclick="window.location.href='https://github.com/szvone/vmqphp';"/></p>-->
        </article>


        <article id="login">
            <h2 class="major">下单</h2>
            <form method="post" action="javascript:login();">
                <div class="field half first">
<!--                    <label for="user">选择商品</label>-->
                    <select  name="user" id="user" lay-verify=""  onchange="setInfo(this.options[this.options.selectedIndex].value);">
                        <option value="0">点击选择商品</option>
                    </select>
                </div>
                <div class="field half" id="isPhomeNum" style="display: none;">
                    <label for="pass">联系方式[**邮箱或者手机**]</label>
                    <input type="text" name="pass" id="phoneContent" minlength="5" required="required"/>
                </div>
                <div class="field half" id="isGoodNum" style="display: none;">
                    <label for="pass">请输入数量</label>
                    <input type="text" name="pass" id="goodNumContent"  oninput="value=value.replace(/[^\d]/g,'')" value="1" required="required"/>
                </div>
                <div class="field half" id="isAddr" style="display: none;">
                    <label for="pass">请输入收货姓名+地址</label>
                    <input type="text" name="pass" id="goodContentAddr" required="required"/>
                </div>
                <div class="field half "  id="payTypeDiv"  style="display: none;">
                    <label for="user">选择支付方式</label>
<!--                    onchange="setInfo(this.options[this.options.selectedIndex].value);"-->
                    <select  name="payType" id="payType" lay-verify=""  >
<!--                        <option value="1">微信</option>-->
                        <option value="2">支付宝</option>
                    </select>
                </div>

                <ul class="actions">
                    <li><input id="login2" type="button" value="下单" class="special" onclick="save()" /></li>
<!--                    <li><input type="reset" value="清空" /></li>-->
                    <li style="  color: 0000;  font-size: 30px;"><div><text id="priceDiv"></text></div></li>
                    <li><div id="tipsDiv"></div></li>
                </ul>
            </form>
            <br>
            <div id="result" role="dialog">
                <p color class="h5 margin-top-sm text-black-hint" id="msg"></p>
            </div>
        </article>

    </div>

    <footer id="footer">
        <p class="copyright">&copy;2022 资源商城</p>
    </footer>

</div>

<div id="bg"></div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="info">详情</a>
</script>
<script src="https://cdn.jsdelivr.net/npm/jquery@1.11.3"></script>
<script src="https://cdn.jsdelivr.net/gh/ajlkn/skel@3.0.1/dist/skel.min.js"></script>
<script src="/assets/js/util.js"></script>
<script src="/assets/js/main.js"></script>
<script src="https://lib.baomitu.com/layer/3.1.1/layer.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/json2/20160511/json2.js"></script>
<script type="text/javascript" src="js/md5.js"></script>
<script src="layui/layui.js?t=1531663423583" charset="utf-8"></script>
<script>
        window.global = {
            pageType: 'demo'
            ,preview: function(){
                var preview = document.getElementById('LAY_preview');
                return preview ? preview.innerHTML : '';
            }()
        };
        layui.config({
            base: 'js/'
            ,version: '1531663423583'
        }).use('global');
    </script>
<script>
   function setInfo(){
        $.post("/admin/getSettings",function (data) {
                        console.log(data);
                        if (data.code==1){
                            $("#key").val(data.data.key);
                        }
                    });
   }
setInfo();
</script>
<script>
    function searchGoodsInfo(){
        var ph=document.getElementById("phoneContentSearch").value;
        layui.use('table',function(){
            var table = layui.table;
            form = layui.form;
<!--            console.log("运行了"+ph);-->

            //第一个实例
            table = table.render({
                 elem: '#showTables'
                ,height: 'full-160'
                ,url: '/searchGoodsInfo?phone='+ph
                ,cols: [[ //表头
                    {field: 'id', title: 'ID' , align:'center',width:"20%"},
                    {field: 'goodsName', title: '名称', align:'center',width:"25%"},
                    {field: 'reallyPrice', title: '金额', align:'center',width:"25%"},
                    {field: 'goodsCon', title: '内容', align:'center',width:"35%"},
                ]]
                ,done: function (res, curr, count) {
                    $('th').css({'background-color': '#999d9c','color': '#fff'});
                }

            });


        });


    }


</script>


<script>
    function save(){
        <!--点击提交，检查数据，提交创建订单，然后跳转支付页面-->
        var opSelectId=document.getElementById("user")[document.getElementById("user").selectedIndex].value;
        var payTypeCon=document.getElementById("payType")[document.getElementById("payType").selectedIndex].value;
        var phoneContentText=document.getElementById("phoneContent").value;
        var goodNumContentText=document.getElementById("goodNumContent").value;
        var goodContentAddrText=document.getElementById("goodContentAddr").value;
        var aa=window.name;
        var isAddr1=aa[2];
        var isNum1=aa[0];
<!--        console.log(isAddr1);-->
<!--        console.log(isNum1);-->


        if(opSelectId==0){
            layer.msg("请选择商品");
        }else if(phoneContentText.length>=5){
            if(isAddr1==1){
                if(goodNumContentText==""||goodNumContentText==null){
                     layer.msg("请输入商品数量！！");
                }else if(isNum1==1){

                     if(goodContentAddrText.length<=10){
                             layer.msg("*收货地址*请至少输入十个数字以上！！");
                     }else{
                        $.post("/getGoods",function (data) {
                        if(data["code"]==1){
                            for(var i=0,len=data["data"].length;i<len;i++){
                                if(data["data"][i]["id"]==opSelectId){
                                     var priceCon=data["data"][i]["price"];
                                     var goodsName=data["data"][i]["goodsName"];
                                     phoneContentText=document.getElementById("phoneContent").value;
                                     goodNumContentText=document.getElementById("goodNumContent").value;
                                     goodContentAddrText=document.getElementById("goodContentAddr").value;
                                     var payId =new Date().getTime();
                                     var key = "7c57f3ddf9a4fa93d649a8a2cbe5227c";
                                     var sign = hex_md5(payId+payTypeCon+priceCon+key);
                                     $.post("/createOrder","payId="+payId+"&type="+payTypeCon+"&price="+priceCon+"&sign="+sign+"&isHtml="+0+"&goodsId="+opSelectId+"&orderPhone="+phoneContentText+"&orderAddr="+goodContentAddrText+"&goodsNum="+goodNumContentText+"&goodsName="+goodsName,function (data) {
                                            data1=JSON.parse(data);
                                            console.log(data);
                                            if (data1["code"]==1){
                                                console.log("进入跳转");
                                                window.location.href="/payPage/pay.html?orderId="+data1["data"]["orderId"];
                                                console.log("完成跳转");
                                            }
                                     });
                                }
                             }
                           }
                        });
                     }
                }else{
                    $.post("/getGoods",function (data) {
                    if(data["code"]==1){
                        for(var i=0,len=data["data"].length;i<len;i++){
                            if(data["data"][i]["id"]==opSelectId){
                                 var priceCon=data["data"][i]["price"];
                                 var goodsName=data["data"][i]["goodsName"];
                                 phoneContentText=document.getElementById("phoneContent").value;
                                 goodNumContentText=document.getElementById("goodNumContent").value;
                                 goodContentAddrText=document.getElementById("goodContentAddr").value;
                                 var payId =new Date().getTime();
                                 var key = "7c57f3ddf9a4fa93d649a8a2cbe5227c";
                                 var sign = hex_md5(payId+payTypeCon+priceCon+key);
                                 $.post("/createOrder","payId="+payId+"&type="+payTypeCon+"&price="+priceCon+"&sign="+sign+"&isHtml="+0+"&goodsId="+opSelectId+"&orderPhone="+phoneContentText+"&orderAddr="+goodContentAddrText+"&goodsNum="+goodNumContentText+"&goodsName="+goodsName,function (data) {
                                        data1=JSON.parse(data);
                                        console.log(data);
                                        if (data1["code"]==1){
                                            console.log("进入跳转");
                                            window.location.href="/payPage/pay.html?orderId="+data1["data"]["orderId"];
                                            console.log("完成跳转");
                                        }
                                 });
                            }
                         }
                       }
                    });
                }
            }else if(isNum1==1){
                if(goodContentAddrText.length<=10){
                             layer.msg("*收货地址*请至少输入十个数字以上！！");
                     }else{
                        $.post("/getGoods",function (data) {
                        if(data["code"]==1){
                            for(var i=0,len=data["data"].length;i<len;i++){
                                if(data["data"][i]["id"]==opSelectId){
                                     var priceCon=data["data"][i]["price"];
                                     var goodsName=data["data"][i]["goodsName"];
                                     phoneContentText=document.getElementById("phoneContent").value;
                                     goodNumContentText=document.getElementById("goodNumContent").value;
                                     goodContentAddrText=document.getElementById("goodContentAddr").value;
                                     var payId =new Date().getTime();
                                     var key = "7c57f3ddf9a4fa93d649a8a2cbe5227c";
                                     var sign = hex_md5(payId+payTypeCon+priceCon+key);
                                     $.post("/createOrder","payId="+payId+"&type="+payTypeCon+"&price="+priceCon+"&sign="+sign+"&isHtml="+0+"&goodsId="+opSelectId+"&orderPhone="+phoneContentText+"&orderAddr="+goodContentAddrText+"&goodsNum="+goodNumContentText+"&goodsName="+goodsName,function (data) {
                                            data1=JSON.parse(data);
                                            console.log(data);
                                            if (data1["code"]==1){
                                                console.log("进入跳转");
                                                window.location.href="/payPage/pay.html?orderId="+data1["data"]["orderId"];
                                                console.log("完成跳转");
                                            }
                                     });
                                }
                             }
                           }
                        });
                     }
            }else{
                $.post("/getGoods",function (data) {
                if(data["code"]==1){
                    for(var i=0,len=data["data"].length;i<len;i++){
                        if(data["data"][i]["id"]==opSelectId){
                             var priceCon=data["data"][i]["price"];
                             var goodsName=data["data"][i]["goodsName"];
                             phoneContentText=document.getElementById("phoneContent").value;
                             goodNumContentText=document.getElementById("goodNumContent").value;
                             goodContentAddrText=document.getElementById("goodContentAddr").value;
                             var payId =new Date().getTime();
                             var key = "7c57f3ddf9a4fa93d649a8a2cbe5227c";
	                         var sign = hex_md5(payId+payTypeCon+priceCon+key);
                             $.post("/createOrder","payId="+payId+"&type="+payTypeCon+"&price="+priceCon+"&sign="+sign+"&isHtml="+0+"&goodsId="+opSelectId+"&orderPhone="+phoneContentText+"&orderAddr="+goodContentAddrText+"&goodsNum="+goodNumContentText+"&goodsName="+goodsName,function (data) {
                                    data1=JSON.parse(data);
                                    console.log(data);
                                    if (data1["code"]==1){
                                        console.log("进入跳转");
                                        window.location.href="/payPage/pay.html?orderId="+data1["data"]["orderId"];
                                        console.log("完成跳转");
                                    }
                             });
                        }
                     }
                   }
                });
            }

        }else{
              layer.msg("*联系方式*请至少输入五个数字");
        }
	}
</script>
<script>
<!--这个方法是获取商品的数据-->
    function getGoods(){
        $.post("/getGoods",function (data) {
             goods_datas=data["data"];
             for(var i=0,len=data["data"].length;i<len;i++){
<!--                 console.log(goods_datas[i]);-->
                 document.getElementById("user").options.add(new Option(goods_datas[i]["goodsName"],goods_datas[i]["id"]));
               }

        });

	}


getGoods();
</script>
<script>
<!--选择下拉框之后，设置显示或隐藏窗口，显示价格和提示信息-->
    function setInfo(obj){
       console.log(obj+"setinfo调用");
       if(obj==0){
       <!--当选择第一个（选择商品）后，所有窗口恢复加载状态-->
           console.log("请选择商品");
           document.getElementById("priceDiv").innerHTML="";
           document.getElementById("tipsDiv").innerHTML="";
           document.getElementById("isAddr").style.display="none";
           document.getElementById("isGoodNum").style.display="none";
           document.getElementById("isPhomeNum").style.display="none";
           document.getElementById("payTypeDiv").style.display="none";

       }else{
           var indexId=obj;
           $.post("/getGoods",function (data) {
            <!--选择好下拉框-，开始设置显示窗口（填写地址，填写数量），或者显示价格或者提示->
             goods_datas=data["data"];
             for(var i=0,len=data["data"].length;i<len;i++){
                 document.getElementById("isPhomeNum").style.display="";
                 document.getElementById("payTypeDiv").style.display="";
                 if(indexId==goods_datas[i]["id"]){
                     <!--           设置跨域传值，是否启用手机号，是否启用地址，是否启用数量，-->
                     var isAddr2=goods_datas[i]["isAddr"];
                     var isNum2=goods_datas[i]["isNum"];
                     var aa=new Array(isNum2,isAddr2)
                     window.name=aa;
                     document.getElementById("priceDiv").innerHTML=goods_datas[i]["price"]+"元";
                     document.getElementById("tipsDiv").innerHTML=goods_datas[i]["tips"];
                     if(goods_datas[i]["isAddr"]==1){
                        document.getElementById("isAddr").style.display="";
                     }else{
                        document.getElementById("isAddr").style.display="none";
                        document.getElementById("goodContentAddr").value="0";
                     }
                                      if(goods_datas[i]["isNum"]==1){
                        document.getElementById("isGoodNum").style.display="";
                     }else{
                        document.getElementById("isGoodNum").style.display="none";
                     }
             }
           }
        })
       }
    }
</script>

</body>
</html>
